package org.lanqiao.oa.dto;

import org.lanqiao.oa.utils.BeanCopierUtil;
import org.lanqiao.oa.vo.PermissionVo;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Repository;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;


@Repository
public class PermissionDTO implements Cloneable{

    interface update{}
    interface insert{}

    private String id;
    private String code;

    @NotNull(groups = {update.class,insert.class})
    @Size(min = 4,max = 20,groups = {update.class,insert.class})
    private String name;
    private String moduleUrl;
    private String operationUrl;
    private Integer orderNo;
    @NotNull(groups = {update.class,insert.class})
    private String pId;
    private String createTime;
    private String editTime;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getModuleUrl() {
        return moduleUrl;
    }

    public void setModuleUrl(String moduleUrl) {
        this.moduleUrl = moduleUrl;
    }

    public String getOperationUrl() {
        return operationUrl;
    }

    public void setOperationUrl(String operationUrl) {
        this.operationUrl = operationUrl;
    }

    public Integer getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(Integer orderNo) {
        this.orderNo = orderNo;
    }

    public String getpId() {
        return pId;
    }

    public void setpId(String pId) {
        this.pId = pId;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getEditTime() {
        return editTime;
    }

    public void setEditTime(String editTime) {
        this.editTime = editTime;
    }

    /**
     * 拷贝对象的方法
     * @param tClass
     * @param <T>
     * @return
     */
    public <T> T copy(Class<T> tClass){
        T t = null;
        try {
            t = tClass.newInstance();
            BeanCopierUtil.copy(this,t);
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return t;

    }


    @Override
    public String toString() {
        return "PermissionDto{" +
                "id='" + id + '\'' +
                ", code='" + code + '\'' +
                ", name='" + name + '\'' +
                ", moduleUrl='" + moduleUrl + '\'' +
                ", operationUrl='" + operationUrl + '\'' +
                ", orderNo=" + orderNo +
                ", pid='" + pId + '\'' +
                ", createTime='" + createTime + '\'' +
                ", editTime='" + editTime + '\'' +
                '}';
    }
}
